package com.zx.service.impl;

import com.zx.entity.User;
import com.zx.mapper.UserMapper;
import com.zx.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author jack.wu
 * @version 1.0
 * @date 2020-03-11
 */
@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User findById(Long id) {
        return userMapper.findById(id).get();
    }

    @Override
    public User addUser(User user) {
        return userMapper.save(user);
    }

    @Override
    public User updateUser(User user) {
        return userMapper.save(user);
    }

    @Override
    public void deleteById(Long id) {
        userMapper.deleteById(id);
    }
}
